#include <iostream>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <vector>
#include <map>
#include <queue>
#include <cstdio>
#include <string>
#include <stack>
#include <set>
#define IOS ios::sync_with_stdio(false), cin.tie(0)
using namespace std;
typedef long long ll;
string s;
ll num[30];
int main()
{
    IOS;
    ll t,cnt=0;
    cin>>t;
    while(t--){
        cin>>s;
        ll len=s.length();
        memset(num,0,sizeof(num));
        for(ll i=0;i<len;i++){
            num[s[i]-'a']++;
        }
        ll ans=1;
        for(ll i=0;i<26;i++){
            ans=max(ans,num[i]);
        }
        cout<<"Case #"<<++cnt<<": "<<ans<<endl;
    }
    getchar();
    getchar();
    return 0;
}
